out of necessity

Translations
по необходимости
She learned to cook out of necessity when she moved out on her own.
Она научилась готовить по необходимости, когда съехала от родителей.
Definitions
A phrase indicating that something is done because it is required or essential, rather than being a choice or preference.